package com.bieyang.anjia.ui.adapter;

import java.util.HashMap;
import java.util.List;

import com.bieyang.anjia.R;
import com.bieyang.anjia.utils.Constants;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class SubDayAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private List<HashMap<String, Object>> list;

	public SubDayAdapter(Context context, List<HashMap<String, Object>> list) {
		inflater = LayoutInflater.from(context);
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HashMap<String, Object> map = list.get(position);
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.sub_set_voice_item, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.check.setChecked((Boolean) map.get(Constants.SUB_CHECK));
		holder.name.setText((String) map.get(Constants.SUB_NAME));
		return convertView;
	}

	public class ViewHolder {
		public CheckBox check;
		public TextView name;

		public ViewHolder(View view) {
			check = (CheckBox) view.findViewById(R.id.setCheck);
			name = (TextView) view.findViewById(R.id.setName);
		}
	}
}
